-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat(worfklow): added cancellation after launching manual execution #796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Summary
This PR implements workflow execution cancellation functionality across the entire execution stack. The changes add the ability for users to cancel running workflows through a UI button, which integrates with a new cancellation mechanism in the core executor.
The implementation follows a clean architecture pattern:
-
Core Executor Changes: The
Executorclass now includes a privateisCancelledboolean flag and a publiccancel()method. The execution loop checks this flag at key points (whileloop condition andcontinueExecutionmethod) to halt processing when cancellation is requested. When cancelled, the executor returns a structured error response with telemetry tracking. -
Hook Integration: The
useWorkflowExecutionhook adds ahandleCancelExecutioncallback that calls the executor's cancel method and properly resets all execution state (including debug state cleanup). It also detects cancellation in streaming executions by checking for the specific error message. -
UI Enhancement: The control bar component conditionally renders a red cancel button with an X icon when
isExecutingis true, replacing the normal run button. This provides immediate visual feedback and user control. -
Test Coverage: Comprehensive test suite covers all cancellation scenarios including basic flag setting, debug mode cancellation, multiple cancel calls, prevention of new execution on cancelled executors, and cancellation during execution loops.
The feature integrates seamlessly with existing execution patterns, supporting both normal and debug mode workflows while maintaining proper state management and telemetry tracking.
Confidence score: 4/5
• This PR is generally safe to merge with well-structured cancellation implementation and comprehensive test coverage
• Score reflects solid implementation but minor concerns about potential race conditions in streaming execution and state cleanup timing
• Files needing attention: use-workflow-execution.ts for streaming cancellation logic and potential executor cleanup timing
4 files reviewed, 1 comment
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts
Outdated
Show resolved
Hide resolved
…imstudioai#796) * feat(worfklow): added cancellation after launching manual execution * fix build error * ack PR comments --------- Co-authored-by: waleedlatif <waleedlatif@waleedlatifs-MacBook-Pro.local>
Description
Added the ability to cancel a run once its been launched. This prevents users with longer workflows from having to wait until the entire run is complete. Speeds up iteration.
Type of change
How Has This Been Tested?
Tested manually
Checklist:
bun run test)Security Considerations:
Screen.Recording.2025-07-26.at.12.00.50.PM.mov